#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn];
map<LL,LL>map1;
int main(void)
{
  cin.tie(0);std::ios::sync_with_stdio(false);
  LL t;cin>>t;
  while(t--){
    LL n;cin>>n;
    map1.clear();
    for(LL i=1;i<=n;i++) cin>>a[i];
    if(n==1){cout<<"0"<<"\n";continue;}
    for(LL i=1;i<n;i++){
        map1[a[i+1]-a[i]]++;
    }
    if(map1.size()==1){
        cout<<"0"<<"\n";
    }
    else if(map1.size()>=2){
        bool flag=1;
        LL c=-1;
        for(LL i=1;i<n;i++){
            if(a[i]<=a[i+1]&&c==-1){
                c=a[i+1]-a[i];
            }
            else if(a[i]<=a[i+1]&&c!=a[i+1]-a[i]){
                flag=0;break;
            }
        }
        LL m=-1;
        for(LL i=1;i<n;i++){
           if(a[i]>=a[i+1]&&m==-1){
               m=abs(a[i]-a[i+1])+c;
           }
           else if(a[i]>=a[i+1]&&m!=abs(a[i]-a[i+1])+c){
               flag=0;break;
           }
        }
        if(flag==0||m<0||c<0||m<=c){
            cout<<"-1"<<"\n";
        }
        else{
            bool ok=1;
            for(LL i=1;i<=n;i++){
                if(m<=a[i]){
                    cout<<"-1"<<"\n";
                    ok=0;
                    break;
                }
            }
            if(ok==1) cout<<m<<" "<<c<<"\n";
        }
    }
  }
return 0;
}
